@ibiz-template-plugin/ai-chat 0.0.97 → 0.0.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -3763,6 +3763,7 @@ const td = () => /* @__PURE__ */ h("svg", { viewBox: "0 0 1024 1024", version: "
3763
3763
  exitSession: "Exit temporary session",
3764
3764
  collapseSidebar: "Collapse the sidebar",
3765
3765
  newConversation: "New conversation",
3766
+ historySession: "History session ({count})",
3766
3767
  newCreateConversation: "Create new conversation",
3767
3768
  searchTopics: "Search topics",
3768
3769
  noTopic: "No topic at the moment",
@@ -3888,6 +3889,7 @@ const td = () => /* @__PURE__ */ h("svg", { viewBox: "0 0 1024 1024", version: "
3888
3889
  exitSession: "退出临时会话",
3889
3890
  collapseSidebar: "收起侧边栏",
3890
3891
  newConversation: "新会话",
3892
+ historySession: "历史会话({count})",
3891
3893
  newCreateConversation: "新建对话",
3892
3894
  searchTopics: "搜索话题",
3893
3895
  noTopic: "暂无话题",
@@ -22347,7 +22349,10 @@ class Ac {
22347
22349
  */
22348
22350
  async searchAIAgent(e) {
22349
22351
  let t = [];
22350
- return this.opts.fetchAgentList ? t = (await this.opts.fetchAgentList(e) || []).map(
22352
+ return this.opts.fetchAgentList ? t = (await this.opts.fetchAgentList({
22353
+ query: e,
22354
+ agentid: this.activeAIAgentID || this.opts.activeAIAgentID
22355
+ }) || []).map(
22351
22356
  (r) => new _c(r, {
22352
22357
  chunkrerank: this.opts.reRankDefaultValue,
22353
22358
  maxchunks: this.opts.maxChunksDefaultValue,
@@ -22662,32 +22667,45 @@ class Ly {
22662
22667
  "aitopics",
22663
22668
  e.type
22664
22669
  ).load();
22665
- this.configList = Array.isArray(i) ? i : [], this.configList && this.configList.length > 0 && (this.resourceMode === "REMOTE" && this.resourceOptions ? (this.remoteSessionList = await this.resourceOptions.getSessionList(), await this.asyncRemoteSession()) : this.configList.forEach((r, s) => {
22666
- Object.prototype.hasOwnProperty.call(r, "sequence") || (r.sequence = s), Object.prototype.hasOwnProperty.call(r, "isTop") || (r.isTop = 0), this.topics.value = [...this.topics.value, new It(r)];
22667
- }));
22670
+ if (this.configList = Array.isArray(i) ? i : [], this.configList && this.configList.length > 0)
22671
+ if (this.resourceMode === "REMOTE" && this.resourceOptions)
22672
+ this.remoteSessionList = await this.resourceOptions.getSessionList(), await this.asyncRemoteSession();
22673
+ else {
22674
+ let r = 1;
22675
+ this.configList.forEach((s, o) => {
22676
+ s.captionComputed || (s.caption = C.t.value("historySession", {
22677
+ count: r
22678
+ }), r += 1), Object.prototype.hasOwnProperty.call(s, "sequence") || (s.sequence = o), Object.prototype.hasOwnProperty.call(s, "isTop") || (s.isTop = 0), this.topics.value = [...this.topics.value, new It(s)];
22679
+ });
22680
+ }
22668
22681
  }
22669
22682
  }
22670
22683
  /**
22671
22684
  * 同步远程会话(以远程会话为准)
22672
22685
  */
22673
22686
  async asyncRemoteSession() {
22674
- !this.remoteSessionList || this.remoteSessionList.length === 0 || this.storageMode === "DEFAULT" && this.configList.length === 0 || this.remoteSessionList.forEach((e) => {
22675
- let t;
22676
- if (this.storageMode === "DEFAULT" && (t = this.configList.find((i) => {
22677
- var r;
22678
- return ((r = i.aiChat) == null ? void 0 : r.sessionid) === e.session_id;
22679
- })), this.storageMode === "REMOTESESSION" && e.ui_meta && (t = Vu(e.ui_meta)), t && t.id) {
22680
- t.realid = e.realid, t.sequence = e.sequence, t.isTop = e.is_top ? e.is_top : 0, e.caption && (t.caption = e.caption);
22681
- const i = this.topics.value.findIndex(
22682
- (r) => {
22683
- var s;
22684
- return ((s = r.aiChat) == null ? void 0 : s.sessionid) === e.session_id;
22687
+ if (!this.remoteSessionList || this.remoteSessionList.length === 0 || this.storageMode === "DEFAULT" && this.configList.length === 0)
22688
+ return;
22689
+ let e = 1;
22690
+ this.remoteSessionList.forEach((t) => {
22691
+ let i;
22692
+ if (this.storageMode === "DEFAULT" && (i = this.configList.find((r) => {
22693
+ var s;
22694
+ return ((s = r.aiChat) == null ? void 0 : s.sessionid) === t.session_id;
22695
+ })), this.storageMode === "REMOTESESSION" && t.ui_meta && (i = Vu(t.ui_meta)), i && !i.captionComputed && (i.caption = C.t.value("historySession", {
22696
+ count: e
22697
+ }), e += 1), i && i.id) {
22698
+ i.realid = t.realid, i.sequence = t.sequence, i.isTop = t.is_top ? t.is_top : 0, t.caption && (i.caption = t.caption);
22699
+ const r = this.topics.value.findIndex(
22700
+ (s) => {
22701
+ var o;
22702
+ return ((o = s.aiChat) == null ? void 0 : o.sessionid) === t.session_id;
22685
22703
  }
22686
22704
  );
22687
- i === -1 ? this.topics.value = [
22705
+ r === -1 ? this.topics.value = [
22688
22706
  ...this.topics.value,
22689
- new It(t)
22690
- ] : (this.topics.value.splice(i, 1, new It(t)), this.topics.value = [...this.topics.value]);
22707
+ new It(i)
22708
+ ] : (this.topics.value.splice(r, 1, new It(i)), this.topics.value = [...this.topics.value]);
22691
22709
  }
22692
22710
  });
22693
22711
  }
@@ -23351,7 +23369,9 @@ class Nf {
23351
23369
  var o;
23352
23370
  e.chatOptions.language && C.setLanguage(e.chatOptions.language), e.chatOptions.locale && C.setLocale(e.chatOptions.locale), this.resourceOptions = e.resourceOptions, (((o = e.resourceOptions) == null ? void 0 : o.resourceMode) || "LOCAL") === "LOCAL" && await this.initIndexDB(), this.backupChatOptions = e;
23353
23371
  const i = e.chatOptions;
23354
- this.setupContainer(e, i), !i.aiAgentlist && i.fetchAgentList && (i.aiAgentlist = await i.fetchAgentList()), !i.aiknowledgeBasesList && i.fetchKnowledgeBaseList && i.enableKnowledgeBaseSelect ? i.aiknowledgeBasesList = await i.fetchKnowledgeBaseList() : i.aiknowledgeBasesList = [];
23372
+ this.setupContainer(e, i), !i.aiAgentlist && i.fetchAgentList && (i.aiAgentlist = await i.fetchAgentList({
23373
+ agentid: i.activeAIAgentID
23374
+ })), !i.aiknowledgeBasesList && i.fetchKnowledgeBaseList && i.enableKnowledgeBaseSelect ? i.aiknowledgeBasesList = await i.fetchKnowledgeBaseList() : i.aiknowledgeBasesList = [];
23355
23375
  let r;
23356
23376
  !e.chatOptions.isSimple && e.mode && e.mode === "TOPIC" ? (this.aiTopic.injectResourceOptions(e.resourceOptions), r = e.topicOptions, Object.assign(r, {
23357
23377
  aiChat: {